package com.pirestupppai.ui.fragment;

import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.pirestupppai.R;
import com.pirestupppai.adapter.VideoListAdapter;
import com.pirestupppai.base.BaseFragment;
import com.pirestupppai.bean.FeedItem;
import com.pirestupppai.widgets.view.EmptyView;
import com.pirestupppai.widgets.view.LoadMoreFooter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 我的合奏
 *
 * author: xiaoluo
 * date: 2017/5/23 14:09
 */
public class VideoMineFragment extends BaseFragment {

    @BindView(R.id.video_mine_recycler_view)
    RecyclerView recyclerView;
    @BindView(R.id.video_mine_swipe_layout)
    SwipeRefreshLayout swipeRefreshLayout;
    @BindView(R.id.video_mine_empty_view)
    EmptyView emptyView;

    private LoadMoreFooter mFooterView;
    private VideoListAdapter mVideoListAdapter;
    private LinearLayoutManager mLinearLayoutManager;

    private long mLastRefreshTime = 0;
    private int mPosition = 0;  // 列表最后一位
    private int mPage = 1;
    private int mSize = 20;
    private boolean hasMore = true;
    private List<FeedItem> mVideoList = new ArrayList<>();

    @Override
    protected Context getFragmentContext() {
        return getActivity();
    }

    @Override
    protected int loadParentLayout() {
        return R.layout.fragment_video_mine;
    }

    @Override
    protected void initViews() {
        mFooterView = new LoadMoreFooter(mContext);
        mVideoListAdapter = new VideoListAdapter(mContext, mVideoList);
        mVideoListAdapter.setFooterView(mFooterView);
        mLinearLayoutManager = new LinearLayoutManager(mContext);
        mLinearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);

        recyclerView.setLayoutManager(mLinearLayoutManager);
        recyclerView.setAdapter(mVideoListAdapter);
        recyclerView.setHasFixedSize(true);
    }

    @Override
    protected void initListeners() {

    }

    @Override
    protected void initLogic() {
//        FeedItem item = new FeedItem();
//        item.setNickname("小落");
//        item.setDesc("爸爸在做啥第二季");
//        item.setCreate_time(1478596668);
//        item.setImage_url(Urls.VIDEO_IMAGE_ONE);
//        item.setAvatar(Urls.MINE_AVATAR);
//        mVideoList.add(item);
//        mVideoListAdapter.notifyDataSetChanged();
    }
}
